Bases: LMOperationalMetric
Seconds per LM call; use to measure latency, not to judge quality.
Computed as elapsed_s / (calls + failed_calls). Because elapsed_s
accumulates each call's own duration, this reports the mean per-call
latency regardless of how many calls ran concurrently -- unlike
Throughput, which divides output tokens by the phase's wall-clock span
and so does reflect concurrency.
Example:
program.compile(
metrics=[
synalinks.metrics.AvgLatency(),
],
)
Source code in synalinks/src/metrics/lm_metrics.py
| @synalinks_export("synalinks.metrics.AvgLatency")
class AvgLatency(LMOperationalMetric):
"""Seconds per LM call; use to measure latency, not to judge quality.
Computed as ``elapsed_s / (calls + failed_calls)``. Because ``elapsed_s``
accumulates each call's own duration, this reports the mean per-call
latency regardless of how many calls ran concurrently -- unlike
`Throughput`, which divides output tokens by the phase's wall-clock span
and so does reflect concurrency.
Example:
```python
program.compile(
metrics=[
synalinks.metrics.AvgLatency(),
],
)
```
"""
def __init__(self, name="avg_latency", description=None):
super().__init__(name=name, description=description)
def result(self):
calls = self._delta("calls") + self._delta("failed_calls")
if calls <= 0:
return 0.0
return self._delta("elapsed_s") / calls
|